ZeroMQ: Fastest. Messaging. Ever.

Mark Leighton Fisher on 2010-06-11T20:07:57

ZeroMQ (or 0MQ) appears to be a fast (8M+ messages/second), Open Source message-passing engine. I don't have a use for it now, but it does look interesting.

(There is no Perl interface for ZeroMQ, but it sounds (without my actually researching the task) like it shouldn't be too hard to clone the Ruby FFI interface for use with Perl.)


Plain XS?

tsee on 2010-06-12T07:56:12

Isn't wrapping it in plain XS the easier and faster route for anything that goes beyond simple types (which are easy to do with FFI)?

Done.

tsee on 2010-06-12T19:45:30

Not using FFI, as noted in my previous reply.

See http://github.com/tsee/ZeroMQ-Perl

Documentation doesn't exist yet. My time for this is pretty much exhausted, so people will have to go by the C++ docs of 0MQ2 itself. If somebody was willing to write a little documentation and maybe write some more tests, we could a) release to CPAN and b) advertise this to 0MQ as a Perl interface for inclusion in their list. I think the documentation should be doable in 1-2 hours.

Re:Done.

tsee on 2010-06-12T20:34:04

Also did some quick timing.

The basic latency test looks promising. For the native C version from 0MQ (running on the client and server on the same dual-core machine via tcp), I get:

message size: 10000 [B]
roundtrip count: 20000
average latency: 32.631 [us]

With my Perl client (C server), I get:

message size: 10000 [B]
roundtrip count: 20000
average latency: 40.767 [us]

I'd say that's pretty damn awesome!

Re:Done.

tsee on 2010-06-12T20:42:23

PS: the message size and roundtrip count are arbitrary. Even for small messages, the Perl wrapper isn't that much slower.

Furthemore, Perl server + Perl client comes in at 48.237 [us] latency, which is seems to indicate that wrapping 0MQ with Perl incurs a penalty of 8us each way. Not bad, could be better.

A Message size of 1 instead of the 10k yields 30us latency for Perl vs Perl.